package com.geeklan.smart.ui.dialog;

import android.content.Context;
import android.view.LayoutInflater;

import com.bigkoo.pickerview.adapter.ArrayWheelAdapter;
import com.geeklan.smart.R;
import com.geeklan.smart.databinding.LayoutListBinding;
import com.geeklan.smart.databinding.LayoutSelectPetWeightBinding;
import com.geeklan.smart.utils.DateUtils;

import java.util.ArrayList;
import java.util.List;

public class ListDialog extends BaseBottomSheetDialog<LayoutListBinding> {
    private List<String> mData = new ArrayList<>();
    public ListDialog(Context context) {
        super(context);
    }

    @Override
    protected LayoutListBinding createContentViewBinding(LayoutInflater inflater) {
        return LayoutListBinding.inflate(inflater);
    }

    @Override
    protected void setupDialog() {
        super.setupDialog();
        setConfirmButtonVisible(true);
        setDialogTitle(R.string.pet_edit);
        setNonFullScreen(0.45f);
//        setContentViewHeight(DensityUtils.dpToPx(mContext,com.smart.base.R.dimen.dp_250));
        setConfirmButtonClickListener(v -> {
            dismiss();
            onBackListener.callback(mBinding.wvList.getCurrentItem());
        });
    }

    public void setupWheelViews(List<String> list){
        mData.clear();
        mData.addAll(list);
        mBinding.wvList.setCyclic(false); // 禁止循环滚动
        mBinding.wvList.setAdapter(new ArrayWheelAdapter<>(mData));
    }

    private OnBackListener onBackListener;

    public void setOnBackListener(OnBackListener onBackListener) {
        this.onBackListener = onBackListener;
    }

    public interface OnBackListener {
        void callback(int position);
    }
}
